<template>
	<div class="download_file">
		<el-button type="text" v-for="(item, index) in data" :key="index" @click="handleDownloadFile(item)">{{ item.name }}</el-button>
	</div>
</template>

<script>
import lodash from 'lodash';
import { attachDownload } from '@/api/global';
export default {
	props: {
		data: { type: Array, default: () => [] }
	},
	methods: {
		async handleDownloadFile(data) {
			console.log(await attachDownload(data.id));
			/* let fileUrl = data.url.setFilePath();
			let suffix = fileUrl.split('.');
			let name = `${data.name}.${data.suffix || lodash.last(suffix)}`;
			console.log(name);
			console.log(fileUrl); */
			/* if (this.data.isSave === '1' && !!this.data.filed5) {
				fileUrl = fileUrl.replace(data.newName, `${data.newName}_name`);
			}
			this.$fileDownload(fileUrl, name); */
		}
	}
};
</script>

<style lang="scss" scoped>
.download_file {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	.el-button {
		font-size: 18px;
		padding: 6px 0;
	}
}
</style>
